<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>2.html</title>
<script type="text/javascript">

    var whichDay = function (date)
    {
        var oneday =
        {
            date : "2016-09-11",
            day : "周日"
        };
        var days = [
                '周日', '周一', '周二', '周三', '周四', '周五', '周六'
        ];
        var reg = /[^\d]/g;/*****这是一个正则表达式，匹配日期*****/
        var ds = date.split (reg);
        var today = new Date (ds[0], ds[1], ds[2]);
        var sds = oneday.date.split (reg);
        var specialDay = new Date (sds[0], sds[1], sds[2]);
        var diff = (today.getTime () - specialDay.getTime ()) / (1000 * 60 * 60 * 24);
        var ok = diff > 0 ? diff % 7 : 7 + diff % 7;
        var result = days[ok];

        console.info (result);
        if(result="周五") {
             alert("周五=小明" + " " +"在学校" + " " + "准备放学回家")
        }else if(result="周四") {
             alert("周四=小花" + " " +"在学校" + " " + "准备去图书馆写作业")
        }else if(result="周日") {
              alert("周日=小方" + " " +"在学校" + " " + "参加期末考试")
        }

        return result;
    }
    whichDay ("2016-09-09");
    whichDay ("2016-09-01");
    whichDay ("2016-09-11");
</script>
</head>
<body>
</body>
</html>
